package com.soup.faker.wrapper;

import java.util.function.Consumer;

public class ValueWrapper<T> {
    private T value;

    public ValueWrapper(T value) {
        this.value = value;
    }

    public ValueWrapper() {
    }

    public T get() {
        return value;
    }

    public void set(T value) {
        this.value = value;
    }

    public static <T> ValueWrapper<T> wrap(T obj) {
        return new ValueWrapper<>(obj);
    }

    public boolean isEmpty() {
        return value == null;
    }

    public void ifPresent(Consumer<T> consumer) {
        if(value != null) {
            consumer.accept(value);
        }
    }

}
